#include <iostream>
#include <cerrno>
#include <cstring>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "comm.h"
using namespace std;

int main()
{
    int wfd = open(FILENAME, O_WRONLY);
    if (wfd < 0)
    {
        std::cerr << "errno:" << errno << ",errstring" << strerror(errno) << std::endl;
        return 1;
    }
    std::string message;
    while (true)
    {
        std::cout << "Plrase Enter ";
        std::getline(std::cin, message);
        ssize_t s = write(wfd, message.c_str(), message.size());
        if (s < 0)
        {
            std::cerr << "errno:" << errno << ",errstring" << strerror(errno) << std::endl;
            break;
        }
    }
    close(wfd);
    return 0;
}